import { queryNoticeList } from '@/services/regulationNotice';

export default {
  namespace: 'regulationNotice',

  state: {
    noticeList: [],
  },

  effects: {
    *queryNoticeList({ payload }, { call, put }) {
      const response = yield call(
        queryNoticeList,
        payload.title,
        payload.source,
        payload.dateStart,
        payload.dateEnd,
        '',
        payload.page_num,
        payload.page_size
      );
      yield put({
        type: 'setNoticeList',
        payload: {
          noticeList: response.data,
        },
      });
    },
  },

  reducers: {
    setNoticeList(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  },
};
